/*
if (flags.get("after_movement_splash_range")) {
if (flags.get("splash_effects_after_movement")) {
for (var i = 0; i < shared.Map.GetAdjacentTiles(unit.Tile).length; i++) {
var splashTiles = shared.Map.GetAdjacentTiles(unit.Tile)[i];
//var range = shared.Map.GetDistance(unit.Tile.X, unit.Tile.Y, splashTiles.X, splashTiles.Y);
say(splashTiles);
}
}
}
*/

if (!global.ShadowMamba) {
global.ShadowMamba = {};
        }
var sm = global.ShadowMamba;

function sm_after_create(c) {
var unit = c.unit;
var flags = unit.ScriptFlags;
if (flags.get("add_random_skills")) {
var addRandomSkill = flags.get("add_random_skills");
var math = Math.random().toFixed(2);
if (flags.get("add_random_skill_chance")) {
var chance = flags.get("add_random_skill_chance");
if (math > chance) {
}
else if (math <= chance) {
var ARS = semiString(addRandomSkill);
var ARSS = ARS.split(",");
for (var i = 0; i < ARSS.length; i++) {
shared.AddSkillToUnit(unit, chooseFromARandomSelectString(ARSS[i]));
}
}
}
if (!flags.get("add_random_skill_chance")) {
var ARS = semiString(addRandomSkill);
var ARSS = ARS.split(",");
for (var i = 0; i < ARSS.length; i++) {
shared.AddSkillToUnit(unit, chooseFromARandomSelectString(ARSS[i]));
}
}
}
if (flags.get("random_name")) {
var randomName = flags.get("random_name");
var names = chooseFromARandomSelectString(randomName);
if (!unit.Name) {
if (unit.Name.indexOf(names) > -1) {
}
else {
unit.Name = names;
}
}
}
if (flags.get("random_inventory_items")) {
sm_randomInventoryItems(c);
}
}

function sm_after_death(d) {
var unit = d.unit;
var flags = unit.ScriptFlags;
var deathSound = flags.get("death_sound");
if (deathSound) {
randomSound(deathSound);
}
}

function unitWasOriginallyFlying(unit) {
var originalUnit = shared.GetUnitObjectByName(unit.IndexedType);
return originalUnit.Flying;
}

function sm_addRandomSkills(a, unit) {
var skill = a.skill;
var item = a.item;
var flags;
if (unit)
flags = unit.ScriptFlags;
if (skill)
flags = skill.ScriptFlags;
if (item)
flags = item.ScriptFlags;
if (flags.get("add_random_skills")) {
var addRandomSkill = flags.get("add_random_skills");
var math = Math.random().toFixed(2);
if (flags.get("add_random_skill_chance")) {
var chance = flags.get("add_random_skill_chance");
if (math > chance) {
}
else if (math <= chance) {
var ARS = semiString(addRandomSkill);
var ARSS = ARS.split(",");
for (var i = 0; i < ARSS.length; i++) {
shared.AddSkillToUnit(unit, chooseFromARandomSelectString(ARSS[i]));
}
}
}
if(!flags.get("add_random_skill_chance")) {
var ARS = semiString(addRandomSkill);
var ARSS = ARS.split(",");
for (var i = 0; i < ARSS.length; i++) {
shared.AddSkillToUnit(unit, chooseFromARandomSelectString(ARSS[i]));
}
}
}
}
